import 'package:boss/models/takeout_business.dart';

import 'package:boss/provider/business_setting_provider.dart';
import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:boss/ui/widget/loader/loader.dart';
import 'package:flutter/material.dart';
import 'package:hi_common/hi_common.dart';
import 'package:provider/provider.dart';
import 'package:async/async.dart';
import 'package:router/annotation.dart';

import 'widget/business_setting_browser.dart';

@RouterConfig(BusinessSettingPage.pageName)
class BusinessSettingPage extends StatefulWidget {
  static const pageName = '/businessSettingPage';

  @override
  _BusinessSettingPageState createState() => _BusinessSettingPageState('营业设置');
}

class _BusinessSettingPageState extends BaseState<BusinessSettingPage> {
  _BusinessSettingPageState(String pageName) : super(pageName);

  Future<Result<TakeoutBusiness>> loadTask() {
    var provider = Provider.of<BusinessSettingProvider>(
      context,
      listen: false,
    );
    return provider.initData();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CenterTitleAppBar(
        title: '外卖设置',
      ),
      body: Loader(
        loadTask: loadTask,
        builder: (context) => BusinessSettingBrowser(),
      ),
    );
  }
}
